<template>
  <div>
    <page-main>
      <el-table
        :data="tableData"
        border
        style="width: 100%;"
        height="50vh"
        v-loading="loading"
      >
        <el-table-column prop="plan_name" label="计划名称"></el-table-column>
        <el-table-column prop="wb_unit_name" label="维保单位"></el-table-column>
        <el-table-column prop="unit_name" label="社会单位"></el-table-column>
        <!-- <el-table-column prop="plan_user_id" label="执业人员"></el-table-column> -->
        <el-table-column
          prop="task_nature"
          label="任务性质"
          :formatter="taskNatureFormatter"
        ></el-table-column>

        <el-table-column prop="sign_in_time " label="签到时间" >
            <template #default="scope">{{$getDateTime(scope.row.sign_in_time)}}</template>
        </el-table-column>
        <el-table-column prop="sign_in_longitude " label="签到经纬度" >
            <template #default="scope">{{scope.row.sign_in_longitude}}{{','+scope.row.sign_in_latitude}}</template>
        </el-table-column>
      </el-table>
      <div class="block">
        <el-pagination
          @current-change="getDateList"
          v-model:currentPage="tableDataInfo.current_page"
          :total="tableDataInfo.total"
          :page-count="tableDataInfo.last_page"
          background
          layout="total,prev, pager, next, jumper"
        >
        </el-pagination>
      </div>
    </page-main>
  </div>
</template>

<script>
export default {
  data() {
    return {
      tableData: [],
      tableDataInfo: "",
      upDataUrl: import.meta.env.DEV
        ? "/proxy/"
        : import.meta.env.VITE_APP_API_BASEURL,
      loading: false,
    };
  },
  created() {
    this.getDateList();
  },
  methods: {
    taskNatureFormatter(row, column, cellValue, index) {
      let temp = {
        1: "计划内",
        2: "业主通知",
        3: "主机报警",
      };
      return temp[cellValue];
    },
    getDateList(page) {
      let unit_id = localStorage.getItem('fa_user_info')
      this.loading = true;
      let pageNum = 1;
      if (page) pageNum = page;
      this.$api
        .post("/unit/Dashboard/dangerList", { type: "outPlanLocationTotal" ,       unit_id:JSON.parse(unit_id).unit_id})
        .then((res) => {
          this.tableData = res.data.list;
          delete res.data.data;
          this.tableDataInfo = res.data;
        })
        .finally(() => {
          this.loading = false;
        });
    },
  },
};
</script>

<style scoped>
.block {
    display: flex;
    justify-content: center;
    margin-top: 10px;
}
</style>
